<template>
  <div class="navbar">
    <el-menu
      :default-active="current"
      class="el-menu-vertical-demo"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      style="border:none"
    >
      <el-menu-item
        v-for="item in navList"
        :key="item.id"
        :index="item.path"
        @click="$router.push(item.path)"
      >
        <i :class="item.icon"></i>
        <span slot="title">{{ item.title }}</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      current: "/home/user",
      navList: [
        {
          id: 1,
          title: "用户管理",
          path: "/home/user",
          icon: "el-icon-user"
        },
        {
          id: 2,
          title: "商品管理",
          path: "/home/goods",
          icon: "el-icon-goods"
        },
        {
          id: 3,
          title: "订单管理",
          path: "/home/order",
          icon: "el-icon-tickets"
        },
        {
          id: 4,
          title: "评论管理",
          path: "/home/comment",
          icon: "el-icon-chat-dot-round"
        }
      ]
    };
  },

  components: {},

  methods: {},

  created() {
    // 刷新页面高亮固定
    this.current = this.$route.path;
  }
};
</script>

<style scoped lang='scss'>
/* 左侧导航栏 */
.navbar {
  position: fixed;
  width: 140px;
  top: 40px;
  left: 0px;
  bottom: 0px;
  overflow-y: auto;
  background-color: #545c64;
  z-index: 10;
}
</style>